﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Channels;
using System.Runtime.Serialization.Formatters;
using System.Collections;

namespace GameServer
{
    public class Server
    {       
        private TcpChannel remotingChannel;       
        private int tcpPortNumber = 7001;        

        public Server(int tcpPort)
        {
            try
            {
                BinaryClientFormatterSinkProvider bcfs = null;
                BinaryServerFormatterSinkProvider bsfs = new BinaryServerFormatterSinkProvider();

                IDictionary dictionary = new Hashtable();

                bsfs.TypeFilterLevel = TypeFilterLevel.Full;
                dictionary = new Hashtable();
                dictionary["port"] = tcpPort;
                dictionary["typeFilterLevel"] = TypeFilterLevel.Full;
                dictionary["name"] = System.Guid.NewGuid().ToString();
                TcpPort = tcpPort;
                remotingChannel = new TcpChannel(dictionary, bcfs, bsfs);
                ChannelServices.RegisterChannel(remotingChannel, false);
                dictionary.Clear();
                dictionary = null;
            }
            catch
            {                
               
            }
           
        }

        public int TcpPort { get; set; }        
    }
}
